package com.zzs.elm.controller;

import java.util.List;

import javax.servlet.http.HttpServletRequest;

import com.zzs.elm.po.Orders;
import com.zzs.elm.service.OrdersService;

public class OrdersController {
	
	private OrdersService service = new OrdersService();
	
	public Object createOrders(HttpServletRequest request) throws Exception{
		String userId = request.getParameter("userId");
		Integer businessId = Integer.valueOf(request.getParameter("businessId"));
		Integer daId = Integer.valueOf(request.getParameter("daId"));
		Double orderTotal = Double.valueOf(request.getParameter("orderTotal"));
		return service.createOrders(userId, businessId, daId, orderTotal);
	}

	public Object getOrdersById(HttpServletRequest request) throws Exception {
		Integer orderId = Integer.valueOf(request.getParameter("orderId"));
		System.out.println(orderId);
		Orders orders = service.getOrdersById(orderId);
		return orders;
	}

	public Object listOrdersByUserId(HttpServletRequest request) throws Exception {
		String userId = request.getParameter("userId");
		List<Orders> list = service.listOrdersByUserId(userId);
		return list;
	}
	
	public Object payOrder(HttpServletRequest request) throws Exception {
		String userId = request.getParameter("userId");
		Integer orderId = Integer.valueOf(request.getParameter("orderId"));
		return service.payOrder(userId, orderId);
		
	}
}
